# coding: utf-8

from enum import Enum, unique

from common.constant import StatusEnum

# 用户每月被驳回次数上线
MONTHLY_REFUSE_MAX = 3

# 试用套餐
TRIAL_BID_POINT = 0
# 使用套餐的代金券
TRIAL_VOUCHER_CNT = 3
TRIAL_VOUCHER_BID_POINT = 200
TRIAL_VOUCHER_DAYS = 30


GIFT_PACK_USER_SET = 'gift_pack_user_set'

HAD_POPUP_PROMPT_SET = 'had_popup_prompt_set'


@unique
class DemandCate(StatusEnum):
    """
    需求分类
    """
    INSTALL = (1, '采购安装')
    MAINTAIN = (2, '维修')
    RENT = (3, '租赁')


BusinessToKeys = {
    DemandCate.INSTALL.value: 'install',
    DemandCate.MAINTAIN.value: 'repair',
    DemandCate.RENT.value: 'rent',
}


# FIXME by chenhj at 2018/5/21 由于客户端需要根据这个渲染业务范围,所以这里不删除采购项
BusinessDisplay = {
    'install': '采购安装',
    'repair': '维修',
    'rent': '租赁',
    'purchase': '采购'
}


@unique
class DemandMalf(StatusEnum):
    """
    故障分类
    """
    OTHER_PROBLEM = (0, '其它')
    BRIGHT_PROBLEM = (1, '整屏或部分不亮')
    BRIGHT_POINT_PROBLEM = (2, '出现亮点暗点')
    COLOR_PROBLEM = (3, '有色彩问题')
    CHANGE_CONENT_PROBLEM = (4, '无法更换屏幕内容')
    SCREEN_SHIFT_PROBLEM = (5, '屏幕移位')


@unique
class DemandType(StatusEnum):
    """
    类型(当cate为安装或维修时使用)
    """
    OUTDOOR_AD_SCREEN = (2, '户外广告屏')
    DOOR_SCREEN = (1, '门头屏')
    INFO_BULLETIN_SCREEN = (3, '信息告示屏')
    STAGE_SCREEN = (4, '舞台用屏')
    INDOOR_SCREEN = (5, '室内高清屏')
    OTHER_SCREEN = (0, '其它类型屏')


@unique
class DemandRentType(StatusEnum):
    """
    created by chenhj at 2017/8/28
    类型(当cate为租赁时使用)
    """
    WEDDING_SCREEN = (1, '婚礼宴会用屏')
    CELEBRATION_SCREEN = (2, '活动庆典用屏')
    STAGE_SCREEN = (3, '舞台演出用屏')
    EXHIBITION_SCREEN = (4, '会议展览用屏')
    OTHER_SCREEN = (0, '其他类型屏')


@unique
class DemandSurr(StatusEnum):
    """
    使用场地
    """
    OUTDOOR = (1, '户外')
    INDOOR = (2, '室内')
    HALF_OUTDOOR = (3, '半户外')
    OTHER = (0, '其它场地')


@unique
class DemandColor(StatusEnum):
    """
    颜色
    """
    FULL_COLOR = (3, '全彩')
    SINGLE_COLOR = (1, '单色')
    DOUBLE_COLOR = (2, '双色')


@unique
class DemandTag(StatusEnum):
    """
    是否虚拟
    """
    NOT_VIRT = (0, '正常订单')
    VIRT_ONE = (1, '金牌已锁定订单')
    VIRT_TWO = (2, '参与人数已达上限订单')
    GOV_RO = (110, '政府招标订单')


@unique
class DemandStatus(StatusEnum):
    """
    状态
    """
    DRAFT = (0, '草稿')
    PUBLISHING = (1, '发布中')
    UNCHECKED = (5, '待审核')
    DELAY = (6, '延后发布')
    MASTER_DISPATCHING = (7, '主人派单')
    BRONZE_MEDAL_DISCOUNT = (8, '优先抢单')
    DISPATCHING = (9, '派单')
    ONGOING = (10, '首次竞价')
    ASSIGN = (11, '分配中')
    BID_DONE = (15, '竞价结束')
    SECOND_ONGOING = (20, '二次竞价')
    FREE_ONGOING = (30, '免费竞价')
    COMPETE_DONE = (100, '抢单结束')
    DONE = (200, '圆满完成')
    # DISCONTINUE = (400, '中止')
    INVALID = (410, '无效')


SECOND_ONGOING_OFFER = 8


@unique
class DemandNoticeWay(StatusEnum):
    """
    项目通知形式
    """
    NO_NOTICE = (0, '不做通知')
    JUST_WX = (1, '已绑定用户,微信通知')
    JUST_SMS = (2, '未绑定用户,短信通知')
    FIRST_WX = (3, '所有用户,优先微信通知')


@unique
class DemandSource(StatusEnum):
    """
    项目来源
    """
    BAIDU = ('百度寻客', '百度寻客')
    LIUDIAN = ('官网留电', '官网留电')
    JIERU400 = ('400接入', '400接入')
    WEIJIE400 = ('400未接', '400未接')
    BAIDU_SEARCH = ('百度搜索', '百度搜索')
    SOGOU_SEARCH = ('搜狗搜索', '搜狗搜索')
    MARKETING_CALLIN = ('客户呼入_百度直推', '客户呼入_百度直推')


# 屏幕默认参数
default_demand_params = {
    DemandType.OUTDOOR_AD_SCREEN.value: {
        'surr': DemandSurr.OUTDOOR.value,
        'color': DemandColor.FULL_COLOR.value,
        'span_choices': ('P6', 'P8', 'P10'),
        'span': 'P10'
    },
    DemandType.INDOOR_SCREEN.value: {
        'surr': DemandSurr.INDOOR.value,
        'color': DemandColor.FULL_COLOR.value,
        'span_choices': ('P1.25', 'P2.0', 'P2.5'),
        'span': 'P2.0'
    },
    DemandType.INFO_BULLETIN_SCREEN.value: {
        'surr': DemandSurr.OUTDOOR.value,
        'color': DemandColor.SINGLE_COLOR.value,
        'span_choices': ('P6', 'P8', 'P10'),
        'span': 'P10'
    },
    DemandType.DOOR_SCREEN.value: {
        'surr': DemandSurr.HALF_OUTDOOR.value,
        'color': DemandColor.SINGLE_COLOR.value,
        'span_choices': ('P10',),
        'span': 'P10'
    },
    DemandType.STAGE_SCREEN.value: {
        'surr': DemandSurr.INDOOR.value,
        'color': DemandColor.FULL_COLOR.value,
        'span_choices': ('P3', 'P4', 'P5'),
        'span': 'P4'
    },
    DemandType.OTHER_SCREEN.value: {
        'surr': DemandSurr.OUTDOOR.value,
        'color': DemandColor.FULL_COLOR.value,
        'span_choices': ('P10',),
        'span': 'P10'
    }
}


# 租赁屏默认参数
default_demand_rent_params = {
    'color': DemandColor.FULL_COLOR.value,
    'surr': DemandSurr.INDOOR.value,
    'span': 'P3.91'
}


@unique
class ParticStatus(StatusEnum):
    """
    抢单参与状态
    """
    DRAFT = (0, '草稿')
    WAITING = (10, '排队中')
    NOT_CONTACT = (110, '竞拍成功待联系')
    BALANCE_NOT_ENOUGH = (120, '竞拍成功但余额不足')
    TIMEOUT_NOT_CONTACT = (130, '超时未联系')
    CALLING = (150, '自动外呼中')
    SUCCEED = (200, '抢单成功')
    TALKED = (300, '聊过天')


# 采购项目中竞标状态的显示
BidStatusDisplay = {
    ParticStatus.WAITING.value: '未中标',
    ParticStatus.SUCCEED.value: '竞标成功',
}


@unique
class UserType(StatusEnum):
    """
    用户类型
    """
    CLIENT = (1, '客户')
    POTENTIAL = (99, '潜在工程商')
    ENGINEER = (100, '工程商')
    CUSTOMER_SERVICE = (200, '客服')
    GROUND_MARKETER = (201, '地推人员')


@unique
class UserStatus(StatusEnum):
    """
    审核状态
    """
    UNVERIFIED = (0, '未认证')
    PENDING = (10, '待审核')
    PASS = (200, '审核通过')
    NOT_PASS = (400, '审核未通过')


@unique
class UserLevel(StatusEnum):
    """
    用户等级
    """
    LEVEL_1 = (0, '无')
    LEVEL_2 = (10, '铁牌')
    LEVEL_3 = (20, '铜牌')
    LEVEL_4 = (30, '银牌')
    LEVEL_5 = (40, '金牌')
    LEVEL_6 = (99, '地方合作伙伴')


@unique
class UserActive(StatusEnum):
    """
    created by chenhj at 2017/8/14

    """
    ACTIVE = (1, '已激活')
    DEACTIVE = (0, '未激活')


@unique
class UserTrainingStatus(StatusEnum):
    """
    created by chenhj at 07/02/2018

    """
    NOT_TRAINING = (0, '不养成')
    TRAINING = (1, '养成')
    PAUSE_TRAINING = (2, '暂停')


@unique
class AreaType(StatusEnum):
    """
    地点类型
    """
    PROV = (1, '省')
    CITY = (2, '市')
    COUNTY = (3, '县/区')


class AreaLevel(StatusEnum):
    """
    created by chenhj at 01/02/2018

    """
    NA = (0, '无')
    FIRST_TIER = (1, '一线城市')
    NORMAL = (2, '常规城市')
    REMOTE = (3, '偏远地区')


@unique
class BillChnl(StatusEnum):
    """
    created by chenhj at 2017/8/8
    交易支付渠道
    """
    ALIPAY = (10, '支付宝')
    WEPAY = (20, '微信')


@unique
class BillType(StatusEnum):
    """
    created by chenhj at 2017/8/7
    交易类型
    """
    INCOMING = (1, '收入')
    PAYMENT = (2, '支出')


@unique
class BillSubType(StatusEnum):
    """
    created by chenhj at 2017/8/8
    交易子类型
    """
    BUY_PACK = (2, '支付并购买抢单套餐')
    HALF_PACK = (3, '九折充值')
    INVITE_BUT_PACK_GIFT = (900, '邀请好友购买套餐赠送')
    GIFT_PACK = (999, '赠送套餐')


@unique
class BillStatus(StatusEnum):
    """
    created by chenhj at 2017/8/7
    交易支付状态
    """
    TO_BE_PAY = (0, '待支付')
    PAID = (200, '支付成功')


@unique
class FollowState(StatusEnum):
    """
    create by ld_wu 2017-08-29
    关注公众号状态
    """
    FOLLOWED = (1, '关注')
    UNFOLLOW = (2, '未关注')
    FOLLOWING = (3, '正在关注')


@unique
class Aspiration(StatusEnum):
    """
    create by ld_wu 2017-08-29
    总体意愿、对金牌会员的预期、
    对成为批发供应商的预期、
    对付费的意愿
    """
    STRONG = (1, '强烈')
    COMMONLY = (2, '一般')
    SLIGHT = (3, '不强烈')


class PaidFeel(StatusEnum):
    """
    create by ld_wu 2017-08-29
    付费后的感受
    """
    WORTH = (1, '很划算')
    COMMONLY = (2, '一般')
    LOSS = (3, '不划算')


class Mastery(StatusEnum):
    """
    专业度
    """
    SENIOR = (1, '资深')
    COMMONLY = (2, '一般')
    NEW = (3, '新人')
    LAYMAN = (4, '非本行业')


class Scale(StatusEnum):
    """
    create by ld_wu 2017-08-29
    实力规模
    """
    LARGE = (1, '大规模（15人以上）')
    MEDIUM = (2, '一般（5-10人）')
    SMALL = (3, '小规模（1-5人）')


class ContactFrequency(StatusEnum):
    """
    create by ld_wu 2017-08-30
    联系频率
    """
    OPEN = (1, '经常')
    OCCASIONALLY = (2, '偶尔（有事联系我）')
    LESS = (3, '尽少（没事别打搅我）')


class Injured(StatusEnum):
    """
    create by ld_wu 2017-08-30
    被伤害程度
    """
    BROKEN = (1, '伤透了(无法回头)')
    BRUISE = (2, '受伤了（还有余地）')
    HYPOCRITICAL = (3, '矫情一下（正在回归）')


ImpressionDisplay = {
    'few_order': '单少',
    'small_order': '单小',
    'fake_order': '单不真实',
    'crowd_order': '抢单人太多',
    'unfair_rule': '规则不公平'
}


SINGLE_CHOICES = [
    ('关注公众号', 'follow_state', FollowState.to_dict()),
    ('总体意愿', 'aspiration', Aspiration.to_dict()),
    ('对金牌会员的预期', 'gold_aspiration', Aspiration.to_dict()),
    ('对成为批发供应商的预期', 'supplier_aspiration', Aspiration.to_dict()),
    ('对付费的意愿', 'pay_aspiration', Aspiration.to_dict()),
    ('对付费后的感受', 'paid_feel', PaidFeel.to_dict()),
    ('专业度', 'mastery', Mastery.to_dict()),
    ('实力规模', 'scale', Scale.to_dict()),
    ('期望联系频率', 'contact_frequency', ContactFrequency.to_dict()),
    ('被伤害程度', 'injured', Injured.to_dict())
]

MULTIPLE_CHOICES = [
    ('对万屏汇的评价', ImpressionDisplay),
    ('业务范围', BusinessDisplay)
]


# 客户列表页开通城市显示最大数量
MAX_AREA_DISPLAY = 20


class WxInviteState(StatusEnum):
    """
    created by chenhj at 2017/9/5

    """
    NA = (-1, '无')
    NOT_BIND = (0, '已邀请未绑定')
    BINDED = (1, '已邀请已绑定')


class DemandFinishImgState(StatusEnum):
    """
    add by zhouhl 2017-09-06
    项目完成图片审核状态
    """

    UNCHECKED = (0, '待审核')
    CHECKED = (1, '审核通过')
    INVALID = (2, '审核不通过')


class UserCreditRule(Enum):
    """
    用户积分增长规则
    """
    LOGIN = 1           # 弃用
    BID = 2             # 弃用
    INVITE = 10
    FINISH_DEMAND_MAINTAIN = 8
    FINISH_DEMAND_RENT = 8
    FINISH_DEMAND_INSTALL = 8
    # 中标(并联系客户)
    WIN_BID = 2
    # 独家锁定
    DEMAND_LOCKED = 6
    # 取消跟进
    GIVE_UP_DEFAULT = 4
    GIVE_UP_MAX = 4
    GIVE_UP_MIN = 0
    # 竞价环节首次出价加1成就值
    ONGOING_OFFER = 1


MAX_ROW_COUNT = 1200


class FeedbackStatus(StatusEnum):
    """
    create by ld_wu 2017-09-12
    反馈审核状态
    """
    REFUSE = (1, '驳回')
    PASS = (2, '通过')
    PENDING = (3, '待审核')


class TemplateLength(object):
    """
    create by ld_wu 2017-10-20
    模板excel的列
    """
    USER = 11
    USER_UPDATE = 2


@unique
class SmsMarketingLevel(StatusEnum):
    """
    短信营销工程商分类
    """
    UNCLASSIFIED = (0, '未分级')
    IS_ENGINEER = (1, '工程商')
    MAYBE_ENGINEER = (2, '疑似工程商')
    NOT_ENGINEER = (3, '非工程商')
    MAYNOT_ENGINEER = (4, '疑似非工程商')


class BidCostType(StatusEnum):
    """
    created by chenhj at 2017/10/31
    套餐数据变更类型
    """
    BID = (1, '抢单')
    PAY = (2, '充值')
    NOT_CONTACT_BACK = (3, '未联系退还')
    NOT_CONTACT_PUNISH = (4, '未联系惩罚')
    NEW = (5, '新用户赠送')
    FEED_BACK = (6, '反馈退还')
    LOCKED = (7, '订单锁定')
    BUY_SMS_POINT = (8, '购买新项目提醒')
    BUY_DISPATCH_POINT = (9, '购买派单点')
    PUBLISH = (10, '发布产品报价扣点')
    BUY_BRONZE_MEDAL_DISCOUNT = (11, '缴纳铜牌会费')
    BRONZE_MEDAL_DISPATCH_POINT_TO_BID_POINT = (12, '铜牌派单点转化为汇币')
    GIFT = (13, '管理员赠送')
    TRANSFER = (14, '转账汇款')
    RECEIVE = (15, '转账收款')
    SMS_END_DATE_TO_BID_POINT = (16, '新项目提醒剩余天数转化为汇币')
    BRONZE_MEDAL_END_DATE_TO_BID_POINT = (17, '铜牌会员剩余天数转化为汇币')
    USE_VOUCHER = (18, '代金券抢单')
    VOUCHER_LOCKED = (19, '代金券锁单')
    SEND_RED_PACKET = (20, '发汇币红包')
    RECEIVE_RED_PACKET = (21, '收汇币红包')
    RED_PACKET_BACK = (22, '过期红包退还')


class ContactState(StatusEnum):
    """
    create by ld_wu 2017-11-30
    """
    NO = (0, '未联系')
    YES = (1, '已联系')


# 爆灯价
MAX_OFFER = 200


class FollowType(StatusEnum):
    """
    created by chenhj at 2017/12/1

    """
    NA = (0, '未跟进')
    LOCKED = (1, '独家锁定')
    KEEP = (2, '继续跟进')
    GIVE_UP = (3, '放弃跟进')


class IncrementPackType(StatusEnum):
    """
    增值套餐类型
    """
    SMS = (1, '新项目提醒套餐')
    DISPATCH = (2, '派单点套餐')
    BRONZE_MEDAL_DISCOUNT = (3, '铜牌会费')


@unique
class SEMGroup(StatusEnum):
    """
    created by zhouhl 2018-01-04
    """
    GroupA = ('02161514624', 'SEM A组')
    GroupB = ('02161514640', 'SEM B组')
    GroupC = ('02161514693', 'SEM C组')


class DemandClientSource(StatusEnum):
    """
    created by chenhj at 15/01/2018

    """
    CALL_IN = (1, '客户呼入')
    LEAVE_MOBILE = (2, '客户留电')
    BAIDU_XUNKE = (3, '百度寻客')
    BAIDU_FORM = (4, '百度表单')
    MARKETING_CALLIN = (5, '客户呼入_百度直推')
    MANUALLY = (99, '手动添加')


class OperateResult(StatusEnum):
    """
    created by chenhj at 15/01/2018

    """
    NA = (0, '未处理')
    INSTALL = (1, '采购安装')
    REPAIR = (2, '维修')
    RENTAL = (3, '租赁')
    INVALID_OP = (10, '无效(不创建订单)')
    INVALID_DEMAND = (11, '无效订单')
    DELAY_OP = (20, '延时处理')
    DELAY_PUBLISH = (21, '延时发布(未发布)')
    DELAY_PUBLISH_DONE = (22, '延时发布(已发布)')
    DONE_BY_OTHER = (30, '已被处理')
    DONE_CAUSE_DUPLICATE = (31, '已被处理(已发过订单)')
    REJECT_MAX = (40, '回呼拒绝达到上限')
    WAIT_FOR_REJECT = (41, '用户拒接, 等待系统回呼')
    DELAY_REJECT_MAX = (42, '延时回呼，用户拒接达到上限')


@unique
class OperatedStatus(StatusEnum):
    NA = (0, '未处理')
    REPUBLISH = (10, '二次发布')
    TRAINING = (20, '赠送')
    INVALID = (30, '作废')


@unique
class MarketingStatus(StatusEnum):
    """
    create by ld_wu 2018-04-24
    营销用户状态
    """
    ACTIVE = (10, '正在营销')
    SUSPEND = (20, '停止营销')


@unique
class UserVisitDemandChannel(StatusEnum):
    """
    add by zhouhl 2018-05-07
    用户访问项目详情的渠道
    """
    WX = (1, '微信公众号')
    APP = (2, '手机APP')


@unique
class GameRewardStatus(StatusEnum):
    """
    add by lina 2018-05-29
    用户奖品兑换状态
    """
    NOT_REWARD = (0, '未兑换')
    REWARD = (1, '已兑换')


@unique
class ApplyRealNumberState(StatusEnum):
    """
    created by chenhj at 2018/6/27

    """
    NA = (0, '未获取')
    GET_BEFORE = (1, '拨前获取')    # 拨打虚拟号前
    GET_AFTER = (2, '拨后获取')     # 拨打虚拟号后


@unique
class RedPacketType(StatusEnum):
    """
    add by zhouhl 2018-07-24
    汇币红包类型
    """
    NORMAL = (1, '普通红包')
    RANDOM = (2, '拼手气红包')
